/*
 * UIComposite.cpp
 */

#include "UIComposite.h"
#include <iostream>

void UIComposite::draw() {
  for (std::list<UIComponent*>::iterator it = _children.begin();
       it != _children.end(); it++) {
    (*it)->draw();
  }
}

UIComposite::CompositeType UIComposite::getType() {
  return _mode;
}

void UIComposite::add(UIComponent* uic) {
  UIComposite* comp = dynamic_cast<UIComposite*>(uic);
  if (comp && (comp->getType() == UIComposite::TOPCONTAINER)) {
    std::cout << "Cannot add a Top Container inside another one." << std::endl;
  } else {
    _children.push_back(uic);
  }
}

void UIComposite::remove(UIComponent* uic) {
  _children.remove(uic);
}

std::list<UIComponent*>& UIComposite::getChildren() {
  return _children;
}

void UIComposite::setDimensions(float width, float height) {
  _width = width;
  _height = height;
}

void UIComposite::setBorderSize(float borderSize) {
  _borderSize = borderSize;
}

void UIComposite::setRoundingCorner(float rounding) {
  _roundingCorner = rounding;
}

void UIComposite::setColors(RGBAColor& background, RGBAColor& border) {
  _colorBackground.set(background.red(), background.green(), background.blue(), background.alpha());
  _colorBorder.set(border.red(), border.green(), border.blue(), border.alpha());
}
